<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Vue 模板</title>
  <script src="https://cdn.bootcss.com/vue/2.6.11/vue.min.js"></script>
  <style>
    .box {
      border: 1px solid red;
      margin-bottom: 50px;
      padding-bottom: 20px;
      padding-left: 10px;
    }
    .tip {
      color: red;
    }
    .hasactive {
      border: 1px solid blue;
    }
    .green-class {
      color: green;
    }
  </style>
</head>
<body>
  <!-- 主控区域 -->
  <div id="app">
    <h1>模板语法</h1>
    <div class="box">
      <h3>v-once</h3>
      <p>msg会改变：{{msg}}</p>
      <p v-once>msg不会改变：{{msg}}</p>
      <p><button @click="change">change</button></p>
    </div>

    <div class="box">
      <h3>v-html</h3>
      <p> {{ vhtml }}</p>
      <p v-html="vhtml"></p>
    </div>

    <div class="box">
      <h3>v-bind</h3>
      <p v-bind:name="pname"> p标签</p>
    </div>
    
    <div class="box">
      <h3>javascript 表达式</h3>
      <p> {{ 1+1 }}</p>
      <p>{{ok ? 'YES' : 'NO'}}</p>
    </div>

    <div class="box">
      <h3>缩写</h3>
      <p :name="pname"> p标签</p>
      <p><button @click="change">点击改变msg变量</button></p>
    </div>
    
  </div>
  
  <script>
    var vue = new Vue({
      el: "#app",
      data: {
        msg: "Hello, World",
        vhtml: 'Using mustaches: <span style="color: red">This should be red.</span>',
        pname: "bindname",
        ok: false,
      },
      methods: {
        change: function () {
          this.msg = "changed"
        }
      }
    })
  </script>
</body>
</html>